/******************************************************************************
** 
** Symbol, word and lines counter.
** 
** File name:	wc.c
** Compilation:	cc wc.c -o wc
** Execution:	./wc
** 
** Description:
** Program counts symbols, words (separated by spaces, newlines or tabs) and 
** individual lines of the input.
** 
******************************************************************************/
#include <stdio.h>

#define IN 1
#define OUT 0

int c, nc, nw, nl, state;

main()
{
  nc = nw = nl = 0;
  state = OUT;
  
  while((c=getchar()) != EOF) {
    ++nc;
    if (c == '\n') {
      ++nl;
    }
    if (c == ' ' || c == '\n' || c == '\t') {
      state = OUT;
    } else if (state == OUT) {
      state = IN;
      ++nw;
    }
  }
  
  printf("Symbols: %d\tWords: %d\t Lines: %d\n", nc, nw, nl);
}

